package cn.zsb.anoprinter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author oldliu
 * @since 1.0
 */
//打印机
@Service
public class Printer {
    //品牌和价格
    @Value("惠普炫彩900")
    private String brand;
    @Value("1000")
    private int price;

    @Autowired//byType
    @Qualifier("caisemoshui")
    private Ink ink;//墨水接口

    //@Resource//默认引用a4
    @Resource(name = "a4")//使用b5,默认是byName
    private TextPaper paper;
    public Printer(){
    }
    public Printer(String brand,int price){
        System.out.println("2个参数的构造方法");
        this.brand=brand;
        this.price=price;
    }

    public void print(String str){
        System.out.println("当前打印机品牌是"+brand+"，价格是"+price);
        System.out.println("使用"+ink.getColor()+"打印");
        paper.print(str);
    }

//    public void setBrand(String brand) {
//        this.brand = brand;
//    }
//
//    public void setPrice(int price) {
//        this.price = price;
//    }
//
//    public void setInk(Ink ink) {
//        this.ink = ink;
//    }
//
//    public void setPaper(TextPaper paper) {
//        this.paper = paper;
//    }
}
